<template>
  <div class="my-tag">
    <input
      class="input"
      type="text"
      placeholder="输入标签"
      v-if="edit"
      v-select
      v-model="tag"
      @blur="changeEdit"
      @keyup.enter="changeEdit"
    />
    <div class="text" v-else @dblclick="showIpt">{{ value }}</div>
  </div>
</template>

<script>
export default {
  components: {},
  props: ['value'],
  data() {
    return {
      edit: false,
      tag: '',
    }
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    showIpt() {
      this.edit = !this.edit
      this.tag = this.value
    },
    changeEdit() {
      this.$emit('input', this.tag)
      this.edit = false
    },
  },
}
</script>

<style scoped lang="less">

.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>
